On the Subject of Thue Morse

Thue Morse Morse Thue Morse Thue Thue Morse Morse Thue Thue Morse Thue Morse Morse Thue

Each time this needy module activates, input the next element of the Thue-Morse sequence (beginning with Thue, then Morse).

If you run out of time or input incorrectly, a strike will be issued and the sequence number will be shown in binary (See Method 2). The sequence will still advance, however.

The Thue-Morse sequence can be constructed in several ways.

Method 1

Begin with a list containing Thue once. Then, whenever you need more elements in the list, duplicate the entire list, swap Thue for Morse and vice versa, and append the new list to the end of the old one.

Method 2

The nth element of the sequence (starting with n equal to zero) can be found by converting n to binary, adding every bit in the number, and taking the result modulo two. A zero represents Thue and a one represents Morse.

Method 3

Begin with a list containing Thue once. Then, replace every occurence of Thue with Thue Morse, and every occurence of Morse with Morse Thue. Repeat as many times as is necessary.